package net.disy.cadenza.repository.workflow;

import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class WorkflowList {
	private Map<String, Workflow> nameToWorkflowMap;
	
	public WorkflowList(Map<String, Workflow> nameToWorkflowMap){
		this.nameToWorkflowMap = nameToWorkflowMap;
	}
	
	public Collection<Workflow> getWorkflows(){
		return nameToWorkflowMap.values();
	}
	
	public Set<Workflow> getWorkflows(String selectorName){
		Set<Workflow> workflowsForSelector = new HashSet<Workflow>();
		for(Workflow workflow : nameToWorkflowMap.values()){
			if(workflow.getSource().getResultSourceData().getSelectorName().equalsIgnoreCase(selectorName))
				workflowsForSelector.add(workflow);
		}
		return workflowsForSelector;
	}
}
